package com.htzos.base.generate.bean;

import java.sql.Date;

public enum ColumnTypeEnum {
	
	VARCHAR(String.class),
	
	CHAR(String.class),
	
	TEXT(String.class),
	
	TINYBLOB(String.class),
	
	TINYTEXT(String.class),
	
	BLOB(String.class),
	
	MEDIUMBLOB(String.class),
	
	MEDIUMTEXT(String.class),
	
	LOGNGBLOB(String.class),
	
	LONGTEXT(String.class),
	
	DATE(Date.class),
	
	TIME(Date.class),
	
	YEAR(Date.class),
	
	DATETIME(Date.class),
	
	TIMESTAMP(Date.class),
	
	TINYINT(Integer.class),
	
	SMALLINT(Integer.class),
	
	MEDIUMINT(Integer.class),
	
	INT(Integer.class),
	
	INTEGER(Integer.class),
	
	BIGINT(Integer.class),
	
	FLOAT(Float.class),
	
	DOUBLE(Double.class),
	
	NUMERIC(Double.class),
	
	UNDEFINED(Object.class);
	
	
	
	private Class objClass;
	
	private ColumnTypeEnum(Class objClass) {
		this.objClass = objClass;
	}
	
	/**
	 * @return the objType
	 */
	public String getObjType() {
		return objClass.getSimpleName();
	}

	/**
	 * @return the objClass
	 */
	public Class getObjClass() {
		return objClass;
	}

	public static ColumnTypeEnum instanceOf(String dbType) {
		
		for (ColumnTypeEnum columnType : ColumnTypeEnum.values()) {
			
			if(columnType.toString().equalsIgnoreCase(dbType)) {
				return columnType;
			}
		}
		
		return UNDEFINED;
	}

}
